home *** CD-ROM | disk | FTP | other *** search
/ Micromanía 92 / CDMM92_1.ISO / SOF 2 SDK / sof2sdk-101.msi / _92D6AC311BB48EBA344BBABC89DA6AB0 / _A193B3109A1B4D80ADDE702D50600C29 < prev    next >
Encoding:
Text File  |  2002-06-12  |  2.6 KB  |  107 lines

  1. // Copyright (C) 2001-2002 Raven Software
  2. //
  3. // cg_gametype.c -- dynamic gametype handling
  4.  
  5. #include "cg_local.h"
  6.  
  7. /*
  8. ===============
  9. CG_ParseGametypeItems
  10. ===============
  11. */
  12. qboolean CG_ParseGametypeItems ( TGPGroup itemsGroup )
  13. {
  14.     TGPGroup  itemGroup;
  15.     int          itemCount;
  16.     char      temp[MAX_QPATH];
  17.  
  18.     // Handle NULL for convienience
  19.     if ( !itemsGroup )
  20.     {
  21.         return qfalse;
  22.     }
  23.  
  24.     // Loop over all the items and add each 
  25.     itemGroup = trap_GPG_GetSubGroups ( itemsGroup );
  26.     itemCount = 0;
  27.  
  28.     while ( itemGroup )
  29.     {
  30.         // Parse icon file
  31.         trap_GPG_FindPairValue ( itemGroup, "icon", "", temp );
  32.         bg_itemlist[ MODELINDEX_GAMETYPE_ITEM + itemCount ].icon = (char *)trap_VM_LocalStringAlloc ( temp );
  33.  
  34.         // Parse display name file
  35.         trap_GPG_FindPairValue ( itemGroup, "displayname", "", temp );
  36.         bg_itemlist[ MODELINDEX_GAMETYPE_ITEM + itemCount ].pickup_name = (char *)trap_VM_LocalStringAlloc ( temp );
  37.  
  38.         // Parse world model file
  39.         trap_GPG_FindPairValue ( itemGroup, "model", "", temp );
  40.         bg_itemlist[ MODELINDEX_GAMETYPE_ITEM + itemCount ].world_model[0] = (char *)trap_VM_LocalStringAlloc ( temp );
  41.  
  42.         trap_GPG_FindPairValue ( itemGroup, "usemodel", "", temp );
  43.         if ( *temp )
  44.         {
  45.             trap_G2API_InitGhoul2Model(&cg_items[MODELINDEX_GAMETYPE_ITEM+itemCount].useModel, temp, 0 , 0, 0, 0, 0);
  46.         }
  47.  
  48.         // Parse bolt model file
  49.         trap_GPG_FindPairValue ( itemGroup, "boltmodel", "", temp );
  50.         if ( *temp )
  51.         {
  52.             trap_G2API_InitGhoul2Model(&cg_items[MODELINDEX_GAMETYPE_ITEM+itemCount].boltModel, temp, 0 , 0, 0, 0, 0);
  53.         }
  54.         cg_items[MODELINDEX_GAMETYPE_ITEM+itemCount].radius[0] = 60;
  55.  
  56.         CG_RegisterItemVisuals ( MODELINDEX_GAMETYPE_ITEM+itemCount );
  57.  
  58.         itemCount++;
  59.  
  60.         // Next sub group
  61.         itemGroup = trap_GPG_GetNext(itemGroup);
  62.     }
  63.  
  64.     return qtrue;
  65. }
  66.  
  67. /*
  68. ===============
  69. CG_ParseGametypeFile
  70. ===============
  71. */
  72. qboolean CG_ParseGametypeFile ( void )
  73. {
  74.     TGenericParser2 GP2;
  75.     TGPGroup        topGroup;
  76.     TGPGroup        gametypeGroup;
  77.  
  78.     // Open the given gametype file
  79.     GP2 = trap_GP_ParseFile ( (char*)cgs.gametypeData->script, qtrue, qfalse );
  80.     if (!GP2)
  81.     {
  82.         return qfalse;
  83.     }
  84.  
  85.     // Grab the top group and the list of sub groups
  86.     topGroup = trap_GP_GetBaseParseGroup(GP2);
  87.     gametypeGroup = trap_GPG_FindSubGroup(topGroup, "gametype" );
  88.     if ( !gametypeGroup )
  89.     {
  90.         trap_GP_Delete(&GP2);
  91.         return qfalse;
  92.     }
  93.     
  94.     // Mainly interested in the items within the file
  95.     CG_ParseGametypeItems ( trap_GPG_FindSubGroup ( gametypeGroup, "items" ) );
  96.  
  97.     // Free up the parser
  98.     trap_GP_Delete(&GP2);
  99.  
  100.     // Defaults
  101.     trap_Cvar_Set ( "ui_blueteamname", "Blue Team" );
  102.     trap_Cvar_Set ( "ui_redteamname", "Red Team" );
  103.  
  104.     return qtrue;
  105. }
  106.  
  107.